﻿using System;
using IWMAG.Core.EnhancedProperties;
using IWMAG.Core.EnhancedProperties.Extensions;

namespace IWMAG.PropertyPrototyper
{
    class SampleObject : PropertyContainerBase
    {
        public SampleObject()
        {
            
        }
        public static PropertyBacker<double> HealthProperty = PropertyManager.Register("Health", 100.0, i => Math.Min(i, 100.0));
        public double Health
        {
            get
            {
                return this.GetValue(HealthProperty);
            }
            set
            {
                this.SetConstantValue(HealthProperty, value);
            }
        }

        public static PropertyBacker<double> DamageProperty = PropertyManager.Register("Damage", 0.0);
        public double Damage
        {
            get
            {
                return this.GetValue(DamageProperty);
            }
            set
            {
                this.SetConstantValue(DamageProperty, value);
            }
        }

        public static PropertyBacker<string> NameProperty = PropertyManager.Register("Name", "SampleObject", CoerceNameProperty);

        private static string CoerceNameProperty(string s)
        {
            if (s.Length < 4)
            {
                return null;
            }
            else
            {
                return s;
            }
        }

        public string Name
        {
            get
            {
                return this.GetValue(NameProperty);
            }
            set
            {
                this.SetConstantValue(NameProperty, value);
            }
        }
    }

}
